﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Administrator_nhanvien_ds : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            load_data();
        }
    }
    private void load_data()
    {
        PagerV2_1.PageSize = 15;
        Criteria c = new Criteria();

        int total = 0;
        if (txt_nv.Text != "0")
        {
            c.add(Condition.AND, Tbl_NhanVien_Columns.TaiKhoan, Condition.LIKE,
               (txt_nv.Text));
        }
        Tbl_NhanVien_Collection nvCollection =
            Tbl_NhanVien_BUS.Get(c.Criter, PagerV2_1.CurrentIndex, PagerV2_1.PageSize,
            Tbl_NhanVien_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
        Repeater1.DataSource = nvCollection;
        Repeater1.DataBind();

        PagerV2_1.ItemCount = total;
    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem ||
            e.Item.ItemType == ListItemType.Item)
        {
            Tbl_NhanVien_Entities nv = (Tbl_NhanVien_Entities)e.Item.DataItem;
            HyperLink hyp_taikhoan = (HyperLink)e.Item.FindControl("hyp_taikhoan");
            Literal lit_mk = (Literal)e.Item.FindControl("lit_mk");
            Literal lit_stt = (Literal)e.Item.FindControl("lit_stt");


            hyp_taikhoan.NavigateUrl = "~/Administrator/nhanvien_ds.aspx?id=" + nv.STT.ToString();
            lit_mk.Text = nv.MatKhau;
            lit_stt.Text = nv.STT.ToString();


            HyperLink hpl_sua = (HyperLink)e.Item.FindControl("hpl_sua");
            hpl_sua.ImageUrl = "~/GiaoDien/images/modify_icon.jpg";
            hpl_sua.NavigateUrl = "~/Administrator/nhanvien_sua.aspx?id=" + nv.STT.ToString();

            HyperLink hpl_xoa = (HyperLink)e.Item.FindControl("hpl_xoa");
            hpl_xoa.ImageUrl = "~/GiaoDien/images/del_icon.jpg";
            hpl_xoa.NavigateUrl = "~/Administrator/delete.aspx?idnv=" + nv.STT.ToString();
        }

    }
    protected void bt_timkiem_Click(object sender, EventArgs e)
    {
        load_data();
    }
}
